package leecode

import "sort"

func LargestSumAfterKNegations(nums []int, k int) int {
	for i := 1; i <= k; i++ {
		sort.Ints(nums)
		nums[0] = -nums[0]
	}
	var result int
	for i := 0; i < len(nums); i++ {
		result += nums[i]
	}
	return result
}
